home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BLACDEMO.ZIP / dist4.inc < prev    next >
Text File  |  1995-05-29  |  6KB  |  318 lines

  1. ; distortion part of demo
  2.  
  3. .data
  4.  
  5. BorderName    db    "border.dat", 0
  6. DistName    db    "mid.dat",0
  7. DistPal        db    "mid.pal",0
  8. CredName    db    "creds.dat",0
  9. CredPal        db    "creds.pal",0
  10. Tab1Ptr        dw    0
  11. Tab2Ptr        dw    0
  12. TempPal        db    768 dup (0)
  13.  
  14. EVEN
  15. Sinetable1 LABEL BYTE
  16. DW 0, 0, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9
  17. DW 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 2, 2, 1 
  18. DW 0, 0, 0, -1, -2, -2, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -8, -9, -9, -9, -9
  19. DW -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -2, -2
  20. DW -1, 0
  21. Stop1    dw $
  22. Sinetable2 LABEL BYTE
  23. DW  0, 0, 128, 128, 256, 256, 384, 384, 512, 512, 512, 640, 640, 768, 768, 896, 896, 896, 1024, 1024, 1024, 1024
  24. DW 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1280, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1024, 1024, 1024, 1024, 896
  25. DW 896, 896, 768, 768, 640, 640, 640, 512, 512, 384, 384, 256, 256, 128, 128, 0, 0, 0, -128, -128, -256, -256
  26. DW -384, -384, -512, -512, -512, -640, -640, -768, -768, -896, -896, -896, -1024, -1024, -1024, -1024, -1152, -1152, -1152, -1152, -1152, -1152
  27. DW -1152, -1152, -1280, -1152, -1152, -1152, -1152, -1152, -1152, -1152, -1152, -1024, -1024, -1024, -1024, -896, -896, -896, -768, -768, -640, -640
  28. DW -640, -512, -512, -384, -384, -256, -256, -128, -128, 0 
  29. Stop2 dw $
  30.  
  31.  
  32. .code
  33.  
  34. DistMap    PROC NEAR
  35.   xor    di, di
  36.   xor    edx, edx
  37.   mov    bx, [Tab1Ptr]        ;horizontal wave (change every line down)
  38.                     ;reset at start only
  39.   PollSB    
  40.   mov    ecx, 800000h        ;128 lines in high word
  41.   maplineloop:
  42.  
  43.     mov    cx, 64            ;128/2 - less loops
  44.     mov    dx, [Tab2Ptr]        ;vertical wave (change per pixel across)
  45.                     ;reset every line
  46.     maploop:        
  47.  
  48. ;@@1    
  49.     mov    si, [bx]
  50.     add    si, [edx]        ;BX+edx (this is the full wave offset)
  51.     add    si, di            ;add offset of where we are now
  52.     and    si, 3FFFh        ;modulus 16384
  53.     
  54.             
  55. ;    add    bx, 2            ;do this here to give the 486 pipeline
  56.     add    dx, 2            ;time to pre-calc address 
  57.     cmp    [Stop2], dx        ;end of list 2?
  58.     je    ResetTab2        ;jump only if equal - less branching
  59.        Comeback2:
  60.  
  61.     mov    al, FS:[si]        
  62.     mov    FS:[di+16384], al        
  63.     inc    di
  64. ; @@2
  65.     mov    si, [bx]
  66.     add    si, [edx]        ;BX+edx (this is the full wave offset)
  67.     add    si, di            ;add offset of where we are now
  68.     and    si, 3FFFh        ;modulus 16384
  69.  
  70. ;    add    bx, 2            ;do this here to give the 486 pipeline
  71.     add    dx, 2            ;time to pre-calc address 
  72.     cmp    [Stop2], dx        ;end of list 2?
  73.     je    ResetTab4        ;jump only if equal - less branching
  74.        Comeback4:
  75.     mov    al, FS:[si]        
  76.     mov    FS:[di+16384], al    
  77.     inc    di
  78.     
  79.  
  80.     dec    cx
  81.     jnz    maploop
  82.  
  83.     add bx, 2    
  84.     cmp    [Stop1], bx        ;end of list 1?
  85.     je    ResetTab1        ;jump only if equal - less branching
  86.    Comeback1:
  87.  
  88.     sub    ecx, 10000h
  89.     jnz    maplineloop        ;next line down
  90.  
  91.     ret
  92.  
  93.  
  94. ResetTab1:
  95.     mov    bx, offset SineTable1    ;reset the ol' pointer
  96.     jmp    Comeback1
  97. ResetTab2:
  98.     mov    dx, offset SineTable2    ;reset
  99.     jmp    Comeback2
  100. ResetTab4:
  101.     mov    dx, offset SineTable2    ;reset
  102.     jmp    Comeback4
  103.  
  104. DistMap    ENDP
  105.  
  106.  
  107. WriteMap    PROC NEAR
  108.     push    ds
  109.     mov    ax, fs
  110.     mov    ds, ax 
  111.     mov    si, 16384        ;start of distorted map
  112.     mov    di, 11616
  113.     
  114.     mov    ecx, 800000h    ;128 in high 2 bytes
  115.  mapline:
  116.      mov    cx, 32        ;32x4=128
  117.      rep    movsd
  118.      add    di, 192
  119.      sub    ecx, 10000h
  120.      jnz    mapline
  121.      
  122.     pop    ds
  123.     ret
  124. WriteMap    ENDP
  125.  
  126. WriteBorder    PROC NEAR
  127.     push    ds
  128.     mov    ax, 0a000h
  129.     mov    es, ax
  130.     mov    ax, fs
  131.     mov    ds, ax
  132.     xor    si, si
  133.     xor    di, di
  134.     
  135.     mov    cx, 16000    ;64000 / 4
  136.     rep    movsd
  137.             
  138.     
  139.     pop    ds
  140.     ret
  141. WriteBorder    ENDP
  142.  
  143.  
  144. DistDemo    PROC NEAR
  145.     PollSB
  146.     mov    bx, 4000    ;short-term 64k buffer disk->mem->VGA
  147.     call    GetMem
  148.     mov    fs, ax        ;save seg
  149.     mov    dx, offset BorderName
  150.     mov    di, 0        ;ax already set to seg by GetMem
  151.     call    LoadData    
  152.  
  153.     PollSB
  154.     mov    dx, offset DistPal
  155.     mov    cx, offset BPalette
  156.     call    LoadPal
  157.     
  158.     mov    si, offset BPalette
  159.     call    SetPal
  160.  
  161.     call    WriteBorder    
  162.     
  163.     
  164.     mov    ax, fs
  165.     mov    es, ax
  166.     call    FreeMem        ;free temporary segment
  167.     
  168.     
  169.     PollSB
  170.     mov    bx, 2048    ;16384 bytes - 128x128
  171.                 ;x2 - one source, one dest
  172.     call    GetMem        ;allocate memory (no mem checking, will
  173.                 ;be enuf if it's got this far)
  174.     mov    fs, ax        ;set FS to picture segment
  175.     mov    [Tab1Ptr], offset SineTable1
  176.     mov    [Tab2Ptr], offset SineTable2    
  177.  
  178.     
  179.     mov    dx, offset DistName
  180.     mov    di, 0        ;placing in buffer - ax already set        
  181.     call    LoadData
  182.  
  183.  
  184.     mov    ax, 0a000h
  185.     mov    es, ax
  186.     
  187. DistortionLoop:
  188.     call    DistMap
  189.     call    WriteMap
  190.     mov    ax, [Tab1Ptr]
  191.     add    ax, 2
  192.     cmp    [Stop1], ax
  193.     ja    NoTabReset1
  194.     mov    ax, offset SineTable1
  195. NoTabReset1:
  196.     mov    [Tab1Ptr], ax
  197.  
  198.     mov    ax, [Tab2Ptr]
  199.     add    ax, 2
  200.     cmp    [Stop2], ax
  201.     ja    NoTabReset2        ;change this!!!
  202.     mov    ax, offset SineTable2
  203. NoTabReset2:
  204.     mov    [Tab2Ptr], ax
  205.  
  206.     call    DistMap            ;this part repeated so Tab2Ptr
  207.     call    WriteMap        ;is incremented at 1/2 the speed
  208.     mov    ax, [Tab1Ptr]
  209.     add    ax, 2
  210.     cmp    [Stop1], ax    
  211.     ja    NoTabReset3
  212.     mov    ax, offset SineTable1
  213. NoTabReset3:
  214.     mov    [Tab1Ptr], ax
  215.     
  216.     mov    ah, 1
  217.     int    16h
  218.     jz    DistortionLoop
  219.     
  220.     mov    ah, 0
  221.     int    16h    
  222.  
  223.     mov    cx, 100
  224. DistFadeLoop:
  225.     push    cx
  226.     mov    bx, 1
  227.     mov    si, offset BPalette
  228.     call    DecPalette
  229.  
  230.     call    DistMap
  231.     call    WriteMap
  232.     mov    ax, [Tab1Ptr]
  233.     add    ax, 2
  234.     cmp    [Stop1], ax
  235.     ja    FNoTabReset1
  236.     mov    ax, offset SineTable1
  237. FNoTabReset1:
  238.     mov    [Tab1Ptr], ax
  239.  
  240.     mov    ax, [Tab2Ptr]
  241.     add    ax, 2
  242.     cmp    [Stop2], ax
  243.     ja    FNoTabReset2        ;change this!!!
  244.     mov    ax, offset SineTable2
  245. FNoTabReset2:
  246.     mov    [Tab2Ptr], ax
  247.  
  248.     call    DistMap            ;this part repeated so Tab2Ptr
  249.     call    WriteMap        ;is incremented at 1/2 the speed
  250.     mov    ax, [Tab1Ptr]
  251.     add    ax, 2
  252.     cmp    [Stop1], ax    
  253.     ja    FNoTabReset3
  254.     mov    ax, offset SineTable1
  255. FNoTabReset3:
  256.     mov    [Tab1Ptr], ax
  257.     
  258.     pop    cx
  259.     dec    cx
  260.     jnz    DistFadeLoop    
  261.         
  262.     mov    ax, fs
  263.     mov    es, ax
  264.     call    FreeMem
  265.     
  266.     PollSB
  267.     mov    bx, 4000        
  268.     call    GetMem            ;reserve 64k mem
  269.     mov    fs, ax
  270.     
  271.     mov    dx, offset CredName
  272.     mov    di, 0
  273.     call    LoadData
  274.     
  275.     PollSB
  276.     mov    dx, offset CredPal
  277.     mov    cx, offset BPalette
  278.     call    LoadPal
  279.     
  280.     call    BlackPal        ;zero palette (incase fade ont complete)
  281.     
  282.     
  283.     call    WriteBorder
  284.     
  285.     mov    cx, 100
  286. ICredLoop:
  287.     push    cx
  288.     call    WaitRetrace        
  289.     mov    si, offset TempPal
  290.     mov    di, offset BPalette
  291.     call    IncPalette
  292.  
  293.     PollSB
  294.     pop    cx
  295.     loop    ICredLoop    
  296.  
  297.  
  298.     mov    cx, 500
  299. CredLoop:
  300.     call    WaitRetrace        ;delay
  301.  
  302.     PollSB
  303.     loop    CredLoop    
  304.  
  305.     
  306.     mov    cx, 100    
  307. FCredLoop:
  308.     push    cx
  309.     call    WaitRetrace
  310.     mov    bx, 1
  311.     mov    si, offset BPalette    ;not optimised - doesn't need it
  312.     call    DecPalette
  313.     PollSB
  314.     pop    cx
  315.     loop    FCredLoop    
  316.     
  317.     ret
  318. DistDemo    ENDP